//package com.woniu.mgr.components;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.woniu.mgr.model.Account;
//import com.woniu.mgr.service.AccountService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeanUtils;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
//@Component
//@Slf4j
//public class BookMallUserDetailsService implements UserDetailsService {
//
//    public static final String ROLE_PREFFIX = "ROLE_";
//    @Resource
//    private AccountService accountService;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//
//        log.info("开始执行查询用户信息操作：{}",username);
//        //1. 根据用户名查询用户
//        Account account = accountService.getOne(new QueryWrapper<Account>().eq("account_name", username));
//        //2. 将本地用户模型适配成security的用户模型
//        System.out.println(account);
//        BookUserDetail bookUserDetail = new BookUserDetail();
//        BeanUtils.copyProperties(account,bookUserDetail);
//        //TODO 从数据库中加载用户的角色和权限
//        bookUserDetail.setAuthorities(AuthorityUtils.createAuthorityList(ROLE_PREFFIX + "MANAGER"));
//        return bookUserDetail;
//    }
//}
